import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable({
  providedIn: 'root'
})
export class StorageService {

  constructor(private store:Storage) { }
  /**
   * webSql存储数据
   * @param key 
   * @param value 
   */
  setWebSQLValue(key: any, value: any): void {
    this.store.set(key, value);
  }
  /**
   * localStorage
   * @param key 
   * @param value 
   */
  static setValue(key: any, value: any): void {
    localStorage.setItem(key, value);
  }
  /**
   * webSql获取某一值
   * @param key 
   */
  getWebSQLValue(key: any): any {
    return this.store.get(key);
  }
  /**
   * localStorage中获取
   * @param key 
   */
  static getValue(key: any): any {
    return localStorage.getItem(key);
  }
  //
  /**
   * 更新存储的数据
   */
  updateValue() {

  }
  /**
   * webSql移除key所对应的值
   * @param key 
   */
  removeWebSQLValue(key: any): void {
    this.store.remove(key);
  }
  static removeValue(key: any): void {
    localStorage.removeItem(key);
  }
  clearAllValue(): void {
    this.store.clear();
  }

  test() {
    return localStorage.getItem("platform");
  }
}
